<title>活动列表</title>
<link type="text/css" href="${ctx}/resources/css/ace.min.1.css"  rel="stylesheet" />
<table>
<#-- 
<tr>
<th>活动类型 :</th>
	<th width="70px;" class="label label-sm label-warning arrowed"><a href="${ctx}/admin/news/list${suffix}">不限</a></th>
	<#assign sTypes = dicSetting.getParameterMap("news.type")> 
	<#list sTypes?keys as key>
		<#if key_index lt 10>
			<th width="70px;" class="label label-sm label-warning arrowed"><a href="${ctx}/admin/news/list${suffix}?type=${key}">${sTypes[key]}</a></th>
		</#if>
	</#list>
</tr> -->
<tr>
<th>新闻状态 :</th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/news/list${suffix}?state=1" >正常</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/news/list${suffix}?state=2" >禁用</a> </th>
</tr>
</table>
<div class="hr hr-5 dotted"></div>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
			<table id="sample-table-1" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>新闻名称</th>
						<th >图片</th>
						<th>简介</th>
						<th>创建时间</th>
						<th>是否推荐</th>
						<th>状态</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
				<#list pager.itemList as u>
					<tr>
						<td><span class="green center">${u.id}</span></td>
						<td>${tagUtils.cutString(u.name,12)}</td>
						<td >
							<#list gsonUtils.getImgsJsonList(u.urlList) as url>
								<span class="profile-picture">
									<img  style="height:105px;width:250px;" src="${tagUtils.getFileFullPath(url)}" />
								</span>
								<#break>
							</#list>
						</td>
						<td>${tagUtils.cutString(u.production,12)}</td>
						<td>
							${u.publishTime!}
						</td>
						<td>
						<#if u.type == 0>
							<span class="label label-sm label arrowed" onmouseover="this.style.cursor='pointer'" title="点击推荐" onclick="doRecommender('${u.id}');">
						<#else>
							<span class="label label-sm label-success arrowed" onmouseover="this.style.cursor='pointer'" title="取消推荐" onclick="doRecommender('${u.id}');">
						</#if>
								${dicSetting.getParameterValue("news.type."+u.type)!}
							</span>
						</td>
						<td>
						<#if u.state == 2>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doUserState(this,'${u.id}');" id="off_state"/>
							<span class="lbl"></span>
						<#else>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doUserState(this,'${u.id}');" checked="checked" id="off_state"/>
							<span class="lbl"></span>
						</#if>
							
						</td>
						<td>
						<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
							<a class="green" href="${ctx}/admin/news/edit-${u.id}${suffix}" alt="编辑">
								<i class="icon-pencil bigger-130"></i>
							</a>
							<a class="red" onclick="isDel('${ctx}/admin/news/delete-${u.id}${suffix}')" alt="Delete">
								<i class="icon-trash bigger-130"></i> 
							</a>
						</div>
						</td>
					</tr>
				</#list>
				</tbody>
			</table>
		</div><!-- /.table-responsive -->
		
		<div class="hr hr-18 dotted hr-double"></div>
		<@h.page pager=pager action="${ctx}/admin/news/list${suffix}" />
	</div><!-- /span -->
</div><!-- /row -->

<#if errorMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer red"></i>
		<span class="pink">${errorMsg}</span>
	</h4>
</#if>

<#if infoMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer green"></i>
		<span class="pink">${infoMsg}</span>
	</h4>
</#if>
<script>
	function isDel(url){
		if(!confirm("确认要删除？")){ 
				return false;		
		}else{
			location.href = url;
		}
	}
function doRecommender(id){
console.log(id);
	$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/news/rec?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			
    			}
	        }
		});
}
function doUserState(checkbox,id) {
		if(checkbox.checked) {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/news/on?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		} else {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/news/off?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		}
	}
$(document).ready(function(){
	RP.addBreadcrumb([ {name:"新闻列表", active: true}]);
	$("#breadcrumbs ul").append('&nbsp;&nbsp;&nbsp;&nbsp;<a href="${ctx}/admin/news/add"><i class="icon-zoom-in"></i><span class="label label-warning arrowed-in arrowed-in arrowed-right">新增新闻</span></a>');
});
</script>